//
//  ST_EngagementLikeTogetherControl.swift
//  btvideo
//
//  Created by mac on 2020/12/3.
//  Copyright © 2020 JarvanZhang. All rights reserved.
//

import UIKit

class ST_EngagementLikeTogetherControl: UIControl {
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        self.cornerRadius = 48/2.0
        self.backgroundColor = UIColor.init(white: 1, alpha: 0.9)
        
        
        self.addSubview(icon_image_view)
        icon_image_view.snp.makeConstraints { (make) in
            make.right.equalToSuperview().offset(-15)
            make.centerY.equalToSuperview()
            make.width.height.equalTo(28)
        }
        
        self.addSubview(titleLabel)
        titleLabel.snp.makeConstraints { (make) in
            make.right.equalTo(icon_image_view.snp.left).offset(-10)
            make.left.equalToSuperview().offset(15)
            make.centerY.equalToSuperview()
        }
        
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
//    MARK: - Properties
    
    override var isSelected: Bool{
        didSet{
         
            icon_image_view.image = !isSelected ? icon_normal_image : icon_selected_image
        }
    }
    
    fileprivate lazy var icon_normal_image = ST_ImageUtils.imageName("EngagementLikeTogether_icon")
        
    fileprivate lazy var icon_selected_image = ST_ImageUtils.imageName("EngagementLikeTogether_icon_sel")
    
    fileprivate lazy var icon_image_view:UIImageView = {
        let control = UIImageView()
        control.image = icon_normal_image
        return control
    }()
    
    
    fileprivate lazy var titleLabel:UILabel = {
        let control = UILabel.init()
        control.text = ""
        control.textColor = UIColor.init(hex: 0x333333)
        control.textAlignment = .center
        control.font = UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.medium)
        return control
    }()
    
    var text = ""{
        didSet{
            
            titleLabel.text = text
            
        }
    }
}
